#ifndef FILTER_H
#define FILTER_H

#include "main.h"

#define LEN_adc 5
#define LEN_speed 5

#define MAX_FILTER_CH_1 1
#define MAX_FILTER_CH_2 2
#define MAX_FILTER_CH_3 3
#define MAX_FILTER_CH_4 4


typedef struct 
{
    uint16_t filter_buf[LEN_adc];
    uint16_t in;
    uint32_t out;
}adc_filter_param;

typedef struct 
{
    float filter_buf[LEN_speed];
    float in;
    float out;
}speed_filter_param_f32;

extern adc_filter_param adc1_filter_ia;
extern adc_filter_param adc1_filter_ib;
extern adc_filter_param adc1_filter_ic;
extern adc_filter_param adc1_filter_ua;
extern adc_filter_param adc1_filter_ub;
extern adc_filter_param adc1_filter_uc;

extern speed_filter_param_f32 speed_filter_L;
extern speed_filter_param_f32 speed_filter_R;

void ADC_One_Filter(uint16_t adc_value, adc_filter_param *adc_filter);
void ADC_Three_Filter(uint16_t adc_value, uint16_t adc_value1, uint16_t adc_value2, adc_filter_param *adc_filter, adc_filter_param *adc_filter1, adc_filter_param *adc_filter2);
void Speed_One_Filter(float speed_value, speed_filter_param_f32 *speed_filter);
float iir_filter_3(float x, unsigned int ch);
#endif
